//
//  QRCodeUtil.m
//  ShortVideo-ccinon
//
//  Created by LIN TONG on 2017/6/20.
//  Copyright © 2017年 LIN TONG. All rights reserved.
//

#import "QRCodeUtil.h"
#import <LBXScanViewStyle.h>
#import <LBXScanViewController.h>
#import "SVQRScannerViewController.h"

@implementation QRCodeUtil
+ (void)pushQRCodeVC:(UIViewController *)fromVC WithCompletionHandler:(void(^)(BOOL success,NSString *result))handler{
    //设置扫码区域参数
    LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
    style.centerUpOffset = 20;
    style.xScanRetangleOffset = 45;
    
    if ([UIScreen mainScreen].bounds.size.height <= 480 )
        {
        //3.5inch 显示的扫码缩小
        style.centerUpOffset = 40;
        style.xScanRetangleOffset = 20;
        }
    
    style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
    style.photoframeLineW = 2.0;
    style.photoframeAngleW = 16;
    style.photoframeAngleH = 16;
    
    style.isNeedShowRetangle = NO;
    style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;
    
    //使用的支付宝里面网格图片
    UIImage *imgFullNet = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_full_net"];
    style.animationImage = imgFullNet;
    
    SVQRScannerViewController *qr = [[SVQRScannerViewController alloc]init];
    qr.style = style;
    qr.isOpenFlash = YES;
    qr.isOpenInterestRect = YES;
    [qr setCompletionHander:handler];
    [fromVC presentViewController:qr animated:YES completion:nil];
}
@end
